#pragma once

#include "GdfSingleton.h"

// Forward declarations
namespace Gdf
{
	class GdfWindowManager;
	class GdfWindow;
	class GdfRenderSystemBase;
	class GdfSceneManager;


	class __GDF_EXPORT GdfFrameListener
	{
	public:
		GdfFrameListener(){}
		~GdfFrameListener(){}

		virtual void PreUpdateFrame(const float32 frameTime) = 0;
		virtual void PostUpdateFrame(const float32 /*frameTime*/){}
	};

}


namespace Gdf
{
	class __GDF_EXPORT GdfRoot : public GdfSingleton<GdfRoot>
	{
	public:
		GdfRoot();
		~GdfRoot();

		bool Initialize(GdfWindow* window);
		void Release();

		int StartRendering();
		void SetEndRendering() { mEndRendering = true; }

		// frame
		void PreUpdateFrame(const float32 frameTime);
		void RenderFrame(const float32 frameTime);
		void PostUpdateFrame(const float32 frameTime);

		void AddFrameListener(GdfFrameListener* listner);
		void DelFrameListener(GdfFrameListener* listner);

		// window
		void AddWindow(GdfWindow* window);

	private:
		
		GdfWindowManager* mWindowManager;
		GdfRenderSystemBase* mRenderSystem;
		GdfSceneManager* mSceneManager;

		typedef std::list<GdfFrameListener*> FrameListenerList;
		FrameListenerList mFrameListeners;
		FrameListenerList mFrameListenerAddReserve;
		FrameListenerList mFrameListenerDelReserve;

		bool mEndRendering;
	};
}
